// component/auctionplate/auctionplate.js
Component({

  properties: {
    auction_live: Array,
    auction_live_count: String,
    lot: Array,
    zero: Object,
    house: Object,
    history: Object
  },

  data: {
    gmtDate: '2021-4-15 00:00:00',
    day: 0,
    hour: 0,
    minute: 0,
    secondsec: 0
  },
  attached: function () {
    setTimeout(() => {
      this.countDown()
      console.log(this.data.history)
    }, 1000)

  },
  methods: {
    countDown() {
      var that = this;
      let timeLeft = that.data.zero.end_time * 1000 - new Date();
      var d, h, m, s, ms;
      if (timeLeft >= 0) {
        d = Math.floor(timeLeft / 1000 / 60 / 60 / 24);
        h = Math.floor(timeLeft / 1000 / 60 / 60 % 24);
        m = Math.floor(timeLeft / 1000 / 60 % 60);
        s = Math.floor(timeLeft / 1000 % 60);
        ms = Math.floor(timeLeft % 1000);
        ms = ms < 100 ? "0" + ms : ms
        var str = ms.toString();
        ms = str.substr(0, 2);
        s = s < 10 ? "0" + s : s
        m = m < 10 ? "0" + m : m
        h = h < 10 ? "0" + h : h
        d = d < 10 ? "0" + d : d
        that.setData({
          day: d,
          hour: h,
          minute: m,
          secondsec: s
        })
        setTimeout(() => {
          that.countDown()
        }, 1000);
      } else {
        that.setData({
          day: '00',
          hour: '00',
          minute: '00',
          secondsec: '00'
        })
        console.log('已截止')
      }
    },
    clickskip(e){
      console.log(e.currentTarget.dataset.id)
      wx.navigateTo({
        url: '/auction/details/index?id='+e.currentTarget.dataset.id,
      })
    },
    clickskip1(){
      wx.navigateTo({
        url: '/auction/myauction/index',
      })
    }
  }
})